<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>
<style>

</style>

<body>
    <header class="aui-bar aui-bar-nav" style="position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            设备故障应答
        </div>
        <!-- <div class="aui-bar-tab-item" style="float:right;margin:auto 15px auto auto" tapmode id="scan" onclick="doScan()">
            <i class="aui-iconfont aui-icon-scan" style="font-size: 1.8rem;"></i>
        </div> -->
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <div style="width:100%;margin-top:5%;"></div>
        <div class="aui-btn " style="margin-left:5%;width:40%;background-color: #FF4500;color: #ffffff;"
            onclick="doSearch('0')"><input style="width:70%;background-color: #FF4500;color: #ffffff;" id="submitMsg" readonly /></div>
        <div class="aui-btn " style="margin-left:5%;width:40%;background-color: #7FFF00;color: #ffffff;"
            onclick="doSearch('2')"><input style="width:70%;background-color: #7FFF00;color: #ffffff;" id="dealMsg" readonly /></div>
        <div style="width:100%;margin-top:2%;"></div>
        <!-- <div class="aui-btn " style="margin-left:5%;width:40%;background-color: #FFD700;color: #ffffff;"
            onclick="doSearch('wtyl')">问题遗留</div>
        <div style="width:100%;margin-top:2%;"></div> -->
        <!-- <div class="aui-searchbar" id="search" style="position: relative;">
            <div class="aui-searchbar-input aui-border-radius">
                <i class="aui-iconfont aui-icon-search"></i>
                <div class="aui-searchbar-input">
                    <form>
                        <input type="search" placeholder="请输入设备编码" id="equipCode">
                    </form>
                </div>
            </div>
            <div class="aui-btn aui-btn-primary" style="margin-right: 0.5rem;background-color: #03a9f4" onclick="doSearch()">搜索</div>
        </div> -->
        <!-- <div class="aui-row ui-selectee">
            <div class="aui-col-xs-4 sortable column ui-sortable">
                <select class="ui-selectee">
              <option value="" class="ui-selectee" style="text-align:center;">状态</option>
            </select>
            </div>
            <div class="aui-col-xs-4 sortable column ui-sortable">
                <select class="ui-selectee">
              <option value="" class="ui-selectee">故障等级</option>
            </select>
            </div>
            <div class="aui-col-xs-4 sortable column ui-sortable">
                <select class="ui-selectee">
              <option value="" class="ui-selectee">全部</option>
            </select>
            </div>
        </div> -->
        <ul class="ui-selectee" id="tbodyHtml">

        </ul>
        <!-- <table class="table" style='width:100%;' id="table">
                <thead>
                    <tr style="text-align: center;background-color: #DCE9F2;color: #467aa7;font-size: 12px;font-weight: bold;">
                        <td algin='center'>序号</td>
                        <td algin='center'>物料号</td>
                        <td algin='center'>批次号</td>
                        <td algin='center'>现有数</td>
                        <td algin='center'>冻结数</td>
                    </tr>
                </thead>
                <tbody id="tbodyHtml">
                </tbody>
            </table> -->
    </div>
    <!-- </div> -->
    <!-- <footer class="aui-bar aui-bar-tab" id="footer">
        <div class="aui-bar-tab-item" tapmode id="scan" onclick="doScan()">
            <i class="aui-iconfont aui-icon-scan aui-text-epblue" style="font-size: 1.8rem"></i>
        </div>
    </footer> -->
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">
    //光标所在id
    var idSelector = "";
    var equipCode = ""; //设备编码
    var statusFlag = "";
    //初始化
    apiready = function () {
        $("#equipCode").focus();
        idSelector = "equipCode";
                getNum();
        doSearch("0");

    }
    // 获取光标所在组件的id
    function getIdSelector() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
    }
    //扫描
    function doScan() {
        var moduleScanner = api.require('moduleScanner');
        var params = {
            top: 150, //扫描窗口的上边距
            width: 250, //扫描窗口的宽
            height: 250, //扫描窗口的高
            useColor: false, //是否使用自己设定的颜色(startColor和endColor),
            //如果不使用设定的颜色就使用默认的那张网格图
            startColor: '#0F08C8FF', //渐变起始颜色
            endColor: '#7F08C8FF', //渐变结束颜色
            animTime: 2200, //扫描动画时间,单位为毫秒
        };
        moduleScanner.toScannerActivityForResult(params, function (ret, err) {
            //alert(ret);扫码的结果都是编码
            //1：设备编码
            if (idSelector == 'equipCode') {

                $("#equipCode").val(ret);
                //查询仓库
                //getWorkCenter(ret, idSelector);
            }
        });
    }

    //获得提交和处理数据条数
    function getNum(status) {
        if (status == '0') {
            if (statusFlag == '0') {
                statusFlag = ''
            } else {
                statusFlag = '0'
            }
        }
        if (status == '2') {
            if (statusFlag == '2') {
                statusFlag = ''
            } else {
                statusFlag = '2'
            }
        }
        //设备编码
        var equipCode = $("#equipCode").val();
        if (equipCode != null && equipCode != undefined && equipCode != "") {
            equipCode = equipCode.trim();
        }

        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getEquipmentFaultList";
        var data = {
            values: {
                status: statusFlag,
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 30,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //返回成功
                if (myobj.code == "0") {
                    var list = eval(myobj.list);
                    //计算 状态条数
                    var submitNum = 0;
                    var dealNum = 0;
                    for (var i = 0; i < list.length; i++) {
                        if(list[i].status=='已提交'){
                            submitNum++;
                        }
                        if(list[i].status=='正在维修'){
                            dealNum++;
                        }
                    }
                    $("#submitMsg").val("已提交"+submitNum);
                    $("#dealMsg").val("正在维修"+dealNum);
                    //失败
                } else if (myobj.code == "1") {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }



    //查询
    function doSearch(status) {
        if (status == '0') {
            if (statusFlag == '0') {
                statusFlag = ''
            } else {
                statusFlag = '0'
            }
        }
        if (status == '2') {
            if (statusFlag == '2') {
                statusFlag = ''
            } else {
                statusFlag = '2'
            }
        }
        // if (status == 'wtyl') {
        //     if (statusFlag == 'wtyl') {
        //         statusFlag = ''
        //     } else {
        //         statusFlag = 'wtyl'
        //     }
        // }
        //设备编码
        var equipCode = $("#equipCode").val();
        if (equipCode != null && equipCode != undefined && equipCode != "") {
            equipCode = equipCode.trim();
        }

        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getEquipmentFaultList";
        var data = {
            values: {
                status: statusFlag,
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 30,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //返回成功
                if (myobj.code == "0") {
                    var list = eval(myobj.list);
                    //计算 状态条数
                    var html = "";
                    for (var i = 0; i < list.length; i++) {


                        html += "<li class='sortable ui-selectee ui-sortable'>";
                        html += "<ul class='aui-list aui-media-list ui-selectee'>";
                        html += "<li class='aui-list-item  ui-selectee'>";
                        html += "<div class='aui-media-list-item-inner ui-selectee'>";
                        html += "<div class='aui-list-item-inner ui-selectee'>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>提报时间</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].createDate + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>设备编码</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].equipCode + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>厂房区域</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].locationName + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>资产位置</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].geographiclocation + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>维修状态</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].status + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>设备型号</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].equipModel + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>维修类别</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].ext13 + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>联系方式</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].contact + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>维修描述</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].description + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>首选维修人员</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].jxPerson + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>应答人员</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].ydPerson + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee'>";
                        // html += "<div class='aui-list-item-label ui-selectee'>" + list[i].createId + "</div>";
                        html += "<div class='aui-list-item-right aui-btn ui-selectee'  onclick='goPageDetail(\"" + list[i].sysid + "\");'>应答</div>";
                        html += "<div class='aui-list-item-right aui-btn ui-selectee' onclick='goPageCxDetail(\"" + list[i].sysid + "\", \"" + list[i].ext13 + "\");'>撤销</div>";
                        // html += "<div class='aui-list-item-right aui-btn ui-selectee'  onclick='goPageCxDetail(\"" + list[i].sysid + "\");'>撤销</div>";
                        html += "</div>";
                        html += "</div>";
                        html += "</div>";
                        html += "</li>";
                        html += "</ul>";
                        html += "</li>";
                    }
                    $api.html($api.byId("tbodyHtml"), html);
                    //失败
                } else if (myobj.code == "1") {
                    //清空表格数据
                    $api.html($api.byId("tbodyHtml"), "");
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    //订单返回按钮
    function closeWin() {
        api.closeWin({});
    }

    //跳转详情页面
    function goPageDetail(sysid) {
        //打开页面
        api.openWin({
            name: 'emEquipmentPersonList_yd',
            url: 'emEquipmentPersonList_yd.html',
            pageParam: {
                name: "emEquipmentFaultYD",
                sysid: sysid,
            },
        });
    }

    //跳转撤销页面
    function goPageCxDetail(sysid,ext13) {
        //打开页面
        api.openWin({
            name: 'emEquipmentPersonList_cx',
            url: 'emEquipmentPersonList_cx.html',
            pageParam: {
                name: "emEquipmentFaultYD",
                sysid: sysid,
                type: ext13,
            },
        });
    }
</script>

</html>